package com.nio.c5_网络编程.write;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * @author： pang-yun
 * @date： 2021-09-09 11:24
 * 功能目的 ：用于  写  客户端代码
 */

public class WriteClient {
    public static void main(String[] args) throws IOException {
        SocketChannel socketChannel = SocketChannel.open();
        socketChannel.connect(new InetSocketAddress(9999));

        //3. 接收数据
        int count=0;
        while (true){
            ByteBuffer byteBuffer = ByteBuffer.allocate(1024 * 1024);
            int read = socketChannel.read(byteBuffer);
            byteBuffer.clear();
            count+=read;
            System.out.println(count);

        }
    }
}
